package com.preskool.service.impl;

import com.preskool.mapper.SalaryMapper;
import com.preskool.po.Salary;
import com.preskool.service.SalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @param
 * @Author swj
 * @Date 2021/1/6
 * @version1.0
 */
@Service
public class SalaryServiceImpl implements SalaryService {

    /**
     * 查询全部数据,进行分页
     * @return
     */
    @Override
    public List<Salary> findAllPaging(Integer currentPage,Integer pageSize) {
        List<Salary> salaries = salaryMapper.selectAllPaging(currentPage,pageSize);
        return salaries;
    }

    //注入SalaryMapper接口
    @Autowired(required = false)
    private SalaryMapper salaryMapper;

    /**
     * 通过id查询数据
     * @param salid
     * @return
     */
    @Override
    public Salary findPart(Integer salid) {
        Salary salary = salaryMapper.selectByPrimaryKey(salid);
        return salary;
    }

    /**
     * 加薪页面,根据id修改,
     * 使用动态sql添加
     * @param salary
     * @return
     */
    @Override
    public int updateSalary(Salary salary) {
        int i = salaryMapper.updateByPrimaryKeySelective(salary);
        return i;
    }

    /**
     * 将页面数据添加进salary数据表中,并返回插入了x条数据
     * @param salary
     * @return
     */
    @Override
    public int addSalary(Salary salary) {
        int insert = salaryMapper.insertSelective(salary);
        return insert;
    }

    /**
     * 通过id删除单条数据
     * @param salid
     * @return
     */
    @Override
    public int delSalary(Integer salid) {
        int del = salaryMapper.deleteByPrimaryKey(salid);
        return del;
    }


}
